package com.whirl.basic.utils;

import lombok.Data;

/**
 * @author xiaowei
 * @date 2022/6/13 12:25
 */
@Data
public class AjaxResult {
    private boolean success = true;
    private String message = "OK";
    private Object data;
    /**
     * 链式语法
     */
    public AjaxResult setMessage(String message) {
        this.message = message;
        return this;
    }
    public AjaxResult setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public static AjaxResult createSuccess() {
        return new AjaxResult();
    }
    public static AjaxResult createError() {
        return new AjaxResult().setSuccess(false).setMessage("网络异常");
    }
    public static AjaxResult createError(String message) {
        return new AjaxResult().setSuccess(false).setMessage(message);
    }
}
